﻿package com.firewolf.spring.transaction.byxml;

import java.util.Arrays;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class XMLMainDriver {
	
	private ApplicationContext ctx = null;
	
	private BookShopService service = null;
	
	{
		ctx = new ClassPathXmlApplicationContext("byxml.xml");
		service = ctx.getBean(BookShopService.class);
	}
	
	
	/**
	 * 测试事务
	 * @throws Exception
	 */
	@Test
	public void testBuyBook() throws Exception{
		service.buyBook("1001", "liuxing");
	}
	
	@Test
	public void testBatchBuyBook() throws Exception{
		BatchBookShopService batchService = (BatchBookShopService) ctx.getBean("batchService");
		batchService.bacthBuyBooks("liuxing", Arrays.asList("1001","1002"));
	}
}
